
***Global value chain integration and quality of institutions: Implications for multidimensional energy poverty in African countries’’

//////by Romus Noufelie and Landry Boris Djamen

import  excel "C:\Users\USER\Desktop\UPDATED database GVC QI Energypoverty.xlsx", sheet("Feuil1") firstrow clear

destring CFT CFTR CFTU ELE ELER ELEU GDP FDI TRADE POLS REQ VAC CC GOF, replace force

encode CountryCode, gen(id)

xtset id year

which xtcd2
*! xtcd2 4.1 May 2023
*! author Jan Ditzen
*! see viewsource xtcd2.ado for more info.

. which xtdcce2
*! xtdcce2 4.6 - 09.01.2024
*! author Jan Ditzen
*! www.jan.ditzen.net - jan.ditzen@unibz.it
*! see viewsource xtdcce2.ado for more info.



gen LTRADE=log(TRADE)
gen LUPOP=log(UPOP)
gen LGDP=log(GDP)
gen LFDI=log(FDI)
gen LGVC=log(GVC)
gen LFVA=log(FVA)
gen LDVX=log(DVX)
gen LCFT=log(CFT)
gen LCFTU=log(CFTU)
gen LCFTR=log(CFTR)
gen LELE=log(ELE)
gen LELEU=log(ELEU)
gen LELER=log(ELER)


gen LGVCxCC=LGVC*CC
gen LGVCxGOF=LGVC*GOF
gen LGVCxVAC=LGVC*VAC
gen LGVCxREQ=LGVC*REQ
gen LGVCxPOLS=LGVC*POLS
//////////Generate Quality of institution index (QII)

pca POLS CC GOF REQ VAC
screeplot, yline(1) ci(het)
rotate
predict QII

gen LGVCxQII=LGVC*QII
gen LFVAxQII=LFVA*QII
gen LDVXxQII=LDVX*QII
/////////////////// ENERGY POVERTY
gen CFP=(100-CFT)
gen CFUP=(100-CFTU)
gen CFRP=(100-CFTR)
gen ELEP=(100-ELE)
gen ELEUP=(100-ELEU)
gen ELERP=(100-ELER)

gen LCFP=log(100-CFT)
gen LCFUP=log(100-CFTU)
gen LCFRP=log(100-CFTR)
gen LELEP=log(100-ELE)
gen LELEUP=log(100-ELEU)
gen LELERP=log(100-ELER)
gen LGCFT=log(CFRP-CFUP)
gen LGELEP=log(ELERP-ELEUP)


/////////////////////////// Overall Muldimentional energy poverty  (MEPI)
pca CFP  ELEP
screeplot, yline(1) ci(het)
rotate
predict MEPI
gen LMEPI=log(MEPI)
///////////////////// Generate Multidional and sub-Muldimentional energy poverty 
/// For URBAN Area: UMEPI
pca ELEUP CFUP
screeplot, yline(1) ci(het)
rotate
predict UMEPI
gen LUMEPI=log(UMEPI)
/// RURAL area: RMEPI
pca ELERP CFRP
screeplot, yline(1) ci(het)
rotate
predict RMEPI
gen LRMEPI=log(RMEPI)
///// Rural-Urban gap in  Muldimentional energy poverty 
gen LGMEPI=log(RMEPI-UMEPI)




////// Descriptive statistic///////////////////////////////
sum LMEPI LGVC QII LGDP LUPOP LTRADE LFDI

corr LMEPI LGVC QII LGDP LUPOP LTRADE LFDI

///////multicolienearity test
regres LMEPI LGVC QII LGDP LUPOP LTRADE LFDI
estat vif

//////Cross-sectional dependance test

xtcd2 LMEPI, noest
xtcd2 LGVC, noest
xtcd2 QII, noest
xtcd2 LGDP, noest
xtcd2 LUPOP, noest
xtcd2 LTRADE, noest
xtcd2 LFDI, noest


//////// GVCs, QI and Overal MEPI  (Table 4&5)

xtdcce2 d.LMEPI, lr(L.LMEPI LGVC QII  LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC QII LGDP LUPOP LTRADE LFDI) cr_lags(2/2)
outreg2 using myfile, excel replace

xtdcce2 d.LMEPI, lr(L.LMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI) cr_lags(2/2)
outreg2 using myfile, excel 

*********** GVCs, QI and MEPI in rural areas (Table 4&5)
xtdcce2 d.LRMEPI, lr(L.LRMEPI LGVC QII  LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LRMEPI LGVC QII LGDP LUPOP LTRADE LFDI) cr_lags(1/0)
outreg2 using results.doc, se bdec(3)  word  replace

xtdcce2 d.LRMEPI, lr(L.LRMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LRMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI) cr_lags(0/2)
outreg2 using results.doc, se bdec(3)  word 

*********** GVCs, QI and MEPI in Urban areas (Table 4&5)
xtdcce2 d.LUMEPI, lr(L.LUMEPI LGVC QII  LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LUMEPI LGVC QII LGDP LUPOP LTRADE LFDI) cr_lags(5/2)
outreg2 using myfile, excel 

xtdcce2 d.LUMEPI, lr(L.LUMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LUMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI) cr_lags(5/2)

********************* GVCs, QI and Rura-Urban MEPI gap (Table 6)
xtdcce2 d.LGMEPI, lr(L.LGMEPI LGVC QII  LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LGMEPI LGVC QII LGDP LUPOP LTRADE LFDI) cr_lags(0/0)
outreg2 using myfile, excel 

xtdcce2 d.LGMEPI, lr(L.LGMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LGMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI) cr_lags(0/2)
outreg2 using myfile, excel 


///// ROBUSTNESS CHECK


**********Alternative measure of EP: Poverty in CFT source 

xtdcce2 d.LCFP, lr(L.LCFP LGVC QII  LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LCFP LGVC QII LGDP LUPOP LTRADE LFDI) cr_lags(1/5)
outreg2 using myfile, excel 

xtdcce2 d.LCFP, lr(L.LCFP LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LCFP LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI) cr_lags(1/4)
outreg2 using myfile, excel 

*** Cas of rural CFT access
xtdcce2 d.LCFRP, lr(L.LCFRP  LGVC QII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LCFRP LGVC QII  LGDP LUPOP LTRADE LFDI ) cr_lags(4/5)
outreg2 using myfile, excel 
xtdcce2 d.LELERP, lr(L.LCFRP  LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LCFRP LGVC QII  LGVCxQII LGDP LUPOP LTRADE LFDI ) cr_lags(0/3)
outreg2 using myfile, excel 

*** Cas of Urban CFT access
xtdcce2 d.LCFUP, lr(L.CFUP  LGVC QII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LCFUP LGVC QII  LGDP LUPOP LTRADE LFDI ) cr_lags(2/3)
outreg2 using myfile, excel 
xtdcce2 d.LCFUP, lr(L.CFUP  LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LCFUP LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI ) cr_lags(1/2)
outreg2 using myfile, excel 

*********GAP in rural-Urban poverty in  CFT
xtdcce2 d.LGCFT, lr(L.LGCFT  LGVC QII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LGCFT LGVC QII  LGDP LUPOP LTRADE LFDI ) cr_lags(3/5)
outreg2 using myfile, excel 

xtdcce2 d.LGCFT, lr(L.LGCFT LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LGELEP LGVC LGVCxQII QII  LGDP LUPOP LTRADE LFDI ) cr_lags(0/6)
outreg2 using myfile, excel 

///////////////////////////////////////////////////


**********Alternative measure of EP: Poverty in electricity source
****Poverty in overall electricity access
xtdcce2 d.LELEP, lr(L.ELEP  LGVC QII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LELEP LGVC QII  LGDP LUPOP LTRADE LFDI ) cr_lags(1/5)
outreg2 using myfile, excel 

xtdcce2 d.LELEP, lr(L.ELEP  LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LELEP LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI ) cr_lags(0)
outreg2 using myfile, excel 

*** Cas of rural electricity access
xtdcce2 d.LELERP, lr(L.LELERP  LGVC QII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LELERP LGVC QII  LGDP LUPOP LTRADE LFDI ) cr_lags(0)
outreg2 using myfile, excel replace
xtdcce2 d.LELERP, lr(L.LELERP  LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LELERP LGVC QII  LGVCxQII LGDP LUPOP LTRADE LFDI ) cr_lags(0)
outreg2 using myfile, excel 

*** Cas of urban electricity access
xtdcce2 d.LELEUP, lr(L.ELEUP  LGVC QII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LELEUP LGVC QII  LGDP LUPOP LTRADE LFDI ) cr_lags(0/3)
outreg2 using myfile, excel 
xtdcce2 d.LELEUP, lr(L.ELEUP  LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LELEUP LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI ) cr_lags(0/1)
outreg2 using myfile, excel 

*** gap in rural-urban electricity access
xtdcce2 d.LGELEP, lr(L.LGELEP  LGVC QII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LGELEP LGVC QII  LGDP LUPOP LTRADE LFDI ) cr_lags(3/5)
outreg2 using myfile, excel 

xtdcce2 d.LGELEP, lr(L.LGELEP  LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LGELEP LGVC LGVCxQII QII  LGDP LUPOP LTRADE LFDI ) cr_lags(0/2)
outreg2 using myfile, excel



//////// Robustness for alternative  GVC measures (Table 8) 

xtdcce2 d.LMEPI, lr(L.LMEPI LGVC QII  LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC QII LGDP LUPOP LTRADE LFDI) cr_lags(2/2)
outreg2 using myfile, excel replace

xtdcce2 d.LMEPI, lr(L.LMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI) cr_lags(2/2)
outreg2 using myfile, excel 

xtdcce2 d.LMEPI, lr(L.LMEPI  LFVA QII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LMEPI LFVA QII  LGDP LUPOP LTRADE LFDI ) cr_lags(3/0)
outreg2 using myfile, excel replace
xtdcce2 d.LMEPI, lr(L.LMEPI  LFVA QII LFVAxQII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LMEPI LFVA QII  LFVAxQII LGDP LUPOP LTRADE LFDI ) cr_lags(1/2)
outreg2 using myfile, excel 

xtdcce2 d.LMEPI, lr(L.LMEPI  LDVX QII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LMEPI LDVX QII  LGDP LUPOP LTRADE LFDI ) cr_lags(1/3)
outreg2 using myfile, excel 

xtdcce2 d.LMEPI, lr(L.LMEPI  LDVX QII LDVXxQII LGDP LUPOP LTRADE LFDI ) lr_options(ardl) cr(L.LMEPI LDVX QII  LDVXxQII LGDP LUPOP LTRADE LFDI ) cr_lags(0/0)


////////////// Robustness to alternative measures of Quality of institutions (Tables 9a&b)

xtdcce2 d.LMEPI, lr(L.LMEPI LGVC POLS  LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC POLS LGDP LUPOP LTRADE LFDI) cr_lags(1/2)
outreg2 using myfile, excel replace

xtdcce2 d.LMEPI, lr(L.LMEPI LGVC POLS LGVCxPOLS LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC POLS LGVCxPOLS LGDP LUPOP LTRADE LFDI) cr_lags(0/0)
outreg2 using myfile, excel 


xtdcce2 d.LMEPI, lr(L.LMEPI LGVC CC  LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC CC LGDP LUPOP LTRADE LFDI) cr_lags(1/2)
outreg2 using myfile, excel 
 
xtdcce2 d.LMEPI, lr(L.LMEPI LGVC CC LGVCxCC LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC CC LGVCxCC LGDP LUPOP LTRADE LFDI) cr_lags(2/3)


xtdcce2 d.LMEPI, lr(L.LMEPI LGVC GOF  LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC GOF LGDP LUPOP LTRADE LFDI) cr_lags(2/3)
outreg2 using myfile, excel
 
xtdcce2 d.LMEPI, lr(L.LMEPI LGVC GOF LGVCxGOF LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC GOF LGVCxGOF LGDP LUPOP LTRADE LFDI) cr_lags(2/3)
outreg2 using myfile, excel

xtdcce2 d.LMEPI, lr(L.LMEPI LGVC VAC  LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC VAC LGDP LUPOP LTRADE LFDI) cr_lags(0/2)
outreg2 using myfile, excel
 
xtdcce2 d.LMEPI, lr(L.LMEPI LGVC VAC LGVCxVAC LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC VAC LGVCxVAC LGDP LUPOP LTRADE LFDI) cr_lags(2/1)
outreg2 using myfile, excel

xtdcce2 d.LMEPI, lr(L.LMEPI LGVC REQ LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI LGVC REQ LGDP LUPOP LTRADE LFDI) cr_lags(4/0)
outreg2 using myfile, excel
 
xtdcce2 d.LMEPI, lr(L.LMEPI LGVC REQ LGVCxREQ LGDP LUPOP LTRADE LFDI) lr_options(ardl) cr(L.LMEPI REQ VAC LGVCxREQ LGDP LUPOP LTRADE LFDI) cr_lags(1/2)
outreg2 using myfile, excel




///////// Robustness for assymetric effects (Table 10)


xtqreg  LMEPI LGVC QII LGDP LUPOP LTRADE LFDI, q( 0.25)
outreg2 using myfile, excel replace
xtqreg  LMEPI LGVC QII LGDP LUPOP LTRADE LFDI, q( 0.5)
outreg2 using myfile, excel
xtqreg  LMEPI LGVC QII LGDP LUPOP LTRADE LFDI, q(0.75)
outreg2 using myfile, excel
xtqreg  LMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI, q(0.25)
outreg2 using myfile, excel 
xtqreg  LMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI, q(0.5)
outreg2 using myfile, excel 
xtqreg  LMEPI LGVC QII LGVCxQII LGDP LUPOP LTRADE LFDI, q(0.75)
outreg2 using myfile, excel 
qregplot, ols

///////////////////////Figures


 egen LGVc = mean(LGVC), by(id)  
egen LDVx= mean(LDVX), by(id)
egen LFVa= mean(LFVA), by(id)
egen Qii = mean(QII), by(id)
egen LMEPi = mean(LMEPI), by(id)
egen LGMEPi= mean(LGMEPI), by(id)
egen LUMEPi = mean(LUMEPI), by(id)
egen LRMEPi = mean(LRMEPI), by(id)
***  Fig.1 global value Chain, QI and multiregional energy poverty proxies

twoway (scatter  LMEPi LGVc, mlabel (id ))(lfit LMEPi LGVc), saving(mepi1)
twoway (scatter  LMEPi Qii,  mlabel (id))(lfit LMEPi Qii), saving(mep2)
twoway (scatter  LMEPi LDVx,  mlabel (id))(lfit LMEPi LDVx), saving(mepi03)
twoway (scatter  LMEPi LFVa,  mlabel (id ))(lfit LMEPi LFVa), saving(mepi4)
gr combine  mepi1.gph mep2.gph mepi03.gph mepi4.gph, saving(MEPI11)

*****Fig.2 global value Chain proxies, QI and multidimensional energy poverty
twoway (scatter  LUMEPi LGVc,  mlabel (id ))(lfit LUMEPi LGVc), saving(qi1)
twoway (scatter  LRMEPi LGVc, mlabel (id))(lfit LRMEPi LGVc), saving (qi2)
twoway (scatter  LRMEPi Qii,  mlabel (id ))(lfit LRMEPi Qii), saving(qi3)
twoway (scatter  LUMEPi Qii,  mlabel (id))(lfit LUMEPi Qii), saving(qi4)
twoway (scatter  LGMEPi LGVc,  mlabel (id ))(lfit LGMEPi LGVc), saving(qi5)
twoway (scatter  LGMEPi Qii,  mlabel (id))(lfit LGMEPi Qii), saving(qi6)
gr combine qi1.gph qi2.gph qi3.gph qi4.gph qi5.gph qi6.gph, saving(MEPI2)

****Fig.3 global value Chain proxies and multidimensional energy poverty proxies
twoway (scatter  LUMEPi LFVa,  mlabel (id))(lfit LUMEPi LFVa), saving(f1)
twoway (scatter  LRMEPi LFVa,  mlabel (id))(lfit LRMEPi LFVa), saving(f2)
twoway (scatter  LUMEPi LDVx,  mlabel (id))(lfit LUMEPi LDVx), saving(d1)
twoway (scatter  LRMEPi LDVx,  mlabel (id))(lfit LRMEPi LDVx), saving(d2)
twoway (scatter  LGMEPi LFVa,  mlabel (id))(lfit LGMEPi LFVa), saving(f3)
twoway (scatter  LGMEPi LDVx,  mlabel (id))(lfit LGMEPi LDVx), saving(d3)
gr combine f1.gph f2.gph d1.gph d2.gph f3.gph d3.gph, saving(MEPI3)